package de.dopichaj.labrador.util;

import org.apache.log4j.Logger;

/**
 * Exception handler for unhandled exceptions. Logs the exception and aborts the
 * program.
 */
public final class AbortingExceptionHandler implements Thread.UncaughtExceptionHandler{

    private static final Logger log =
        Logger.getLogger(AbortingExceptionHandler.class);
    
    public void uncaughtException(Thread t, Throwable e) {
        log.error("Uncaught exception in thread " + t, e);
        System.err.println("Aborting due to uncaught exception: " +
            e.getMessage());
        System.exit(-1);
        System.err.println("after exit");
    }
}
